/*** Eclipse Class Decompiler plugin, copyright (c) 2012 Chao Chen (cnfree2000@hotmail.com) ***/
package com.feiyue.basic.reader.util;

import android.content.Context;
import android.os.Handler;
import android.widget.Toast;

public class CustomToast {
	public static final int LENGTH_MAX = -1;
	private boolean mCanceled;
	private Context mContext;
	private Handler mHandler;
	private Toast mToast;

	public CustomToast(Context paramContext) {
		this(paramContext, new Handler());
	}

	public CustomToast(Context paramContext, Handler paramHandler) {
		this.mCanceled = true;
		this.mContext = paramContext;
		this.mHandler = paramHandler;
		this.mToast = Toast.makeText(this.mContext, "", 0);
	}

	private void showUntilCancel() {
		if (this.mCanceled)
			return;
		this.mToast.show();
		this.mHandler.postDelayed(new Runnable() {
			public void run() {
				CustomToast.this.showUntilCancel();
			}
		}, 3000L);
	}

	public void hide() {
		this.mToast.cancel();
		this.mCanceled = true;
	}

	public boolean isShowing() {
		return (!(this.mCanceled));
	}

	//TODO
	public void show(int paramInt1, int paramInt2) {
		this.mToast.setText(paramInt1);
		if (paramInt2 != -1) {
			this.mToast.setDuration(paramInt2);
			this.mToast.show();
		}
//		do
//			return;
//		while (!(this.mCanceled));
//		this.mToast.setDuration(1);
//		this.mCanceled = false;
//		showUntilCancel();
	}

	//TODO
	public void show(String paramString, int paramInt) {
		this.mToast.setText(paramString);
		if (paramInt != -1) {
			this.mToast.setDuration(paramInt);
			this.mToast.show();
		}
//		do
//			return;
//		while (!(this.mCanceled));
//		this.mToast.setDuration(1);
//		this.mCanceled = false;
//		showUntilCancel();
	}
}